home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
sos3-2.lha
/
src
/
knl
/
knl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-23
|
31KB
|
988 lines
/* --------------------------------------------------------------------------
* Copyright 1992 by Forschungszentrum Informatik (FZI)
*
* You can use and distribute this software under the terms of the licence
* you should have received along with this program.
* If not or if you want additional information, write to
* Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
* D-7500 Karlsruhe 1, Germany.
* --------------------------------------------------------------------------
*/
// **************************************************************************
// Module knl 16/06/89 Bernhard Schiefer (bs)
// modified : 09/02/90 (ju)
// 09/08/90 (dt)
// **************************************************************************
// implements methods of classes: sos_Id, sos_Typed_id, sos_Object,
// sos_Ordered_object, sos_Scalar_object
// sos_String, sos_Type
// **************************************************************************
// ==========================================================================
// method implementations for the types of the kernel schema
//
// Tracing conventions:
// - no tracing: module initialization, external type conversions,
// local offset handling, C++ classes (except for allocation)
// - knl_M : generic conversions, container storage allocation,
// local_... methods
// - knl_H : other methods
// ==========================================================================
#include <string.h>
#include <ctype.h>
#include <libc.h> // bcopy
#include "sys.h"
#include "smg.h"
#include "knl_err.h"
#include "trc_knl.h"
#include "mta_use.h"
#include "knl_sos.h"
// ==========================================================================
// quasi constants, module initialization
// ==========================================================================
EXPORT sos_Object NO_OBJECT;
LOCAL sos_Typed_id NOTPID;
LOCAL sos_Id NOID;
LOCAL struct knl_dummy_struct { knl_dummy_struct (); } knl_dummy;
knl_dummy_struct::knl_dummy_struct ()
{ _knl_init_sos(); // needed for 'sos_Object::make'
NOID = sos_Id::make (sos_Container::make (0), 0);
NOTPID = sos_Typed_id::make (NOID, NOID);
NO_OBJECT = sos_Object::make(NOTPID);
}
// ==========================================================================
// local utility methods
// ==========================================================================
// *************************************************************************
LOCAL inline sos_Comp_result make_comp_result (int i)
// *************************************************************************
{ return (i > 0) ? CMP_GREATER
: (i < 0 ) ? CMP_LESS
: CMP_EQUAL;
}
// ==========================================================================
// string conversion operations for the external types of the kernel schema
// ==========================================================================
sos_String make_string_from_sos_Int_object (sos_Object i)
{ sos_String result
= smg_String (make_sos_Int (i)).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Int_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
char *ptr;
long l = strtol (s1, &ptr, 10);
sos_Object result = (ptr != s1 AND ptr[0] == 0)
? make_sos_Int_object (sos_Int (l))
: NO_OBJECT;
delete s1;
return result;
}
sos_String make_string_from_sos_Char_object (sos_Object c)
{ char s [2];
s[0] = make_sos_Char (c);
s[1] = EOS;
sos_String result = smg_String (s).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Char_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
sos_Object result = (strlen (s1) == 1) ? make_sos_Char_object (s1[0])
: NO_OBJECT;
delete s1;
return result;
}
sos_String make_string_from_sos_Pointer_object (sos_Object p)
{ sos_Pointer p1 = make_sos_Pointer (p);
sos_String result
= smg_String ((sos_Int)p1, FALSE).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Pointer_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
char *ptr;
long l = strtol (s1, &ptr, 16);
sos_Object result = (ptr != s1 AND ptr[0] == 0)
? make_sos_Pointer_object (sos_Pointer (l))
: NO_OBJECT;
delete s1;
return result;
}
sos_String make_string_from_sos_Offset_object (sos_Object o)
{ sos_Offset o1 = make_sos_Offset (o);
sos_String result = smg_String (o1).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Offset_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
char *ptr;
long l = strtol (s1, &ptr, 10);
sos_Object result = (ptr != s1 AND ptr[0] == 0)
? make_sos_Offset_object (sos_Offset (l))
: NO_OBJECT;
delete s1;
return result;
}
sos_String make_string_from_sos_Container_object (sos_Object ct)
{ sos_Container ct1 = make_sos_Container (ct);
sos_String result = smg_String (ct1).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Container_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
char *ptr;
long l = strtol (s1, &ptr, 10);
sos_Object result
= (ptr != s1 AND ptr[0] == EOS)
? make_sos_Container_object (sos_Container::make ((int) l))
: NO_OBJECT;
delete s1;
return result;
}
sos_String make_string_from_sos_Cstring_object (sos_Object s)
{ sos_String result
= smg_String (make_sos_Cstring (s)).make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Cstring_object_from_string (sos_String s)
{ sos_Cstring s1 = s.make_Cstring();
sos_Object result = make_sos_Cstring_object (s1);
return result;
}
sos_String make_string_from_sos_Id_object (sos_Object i)
{ sos_Id i1 = make_sos_Id (i);
smg_String s = smg_String("<") + (int)i.container()
+ "," + (int)i.offset() + ">";
sos_String result = s.make_String (TEMP_CONTAINER);
return result;
}
sos_Object make_sos_Id_object_from_string (sos_String s)
{ smg_String s1 = s;
int ct, os, l;
sscanf (s1.make_Cstring (SMG_BORROW), "<%d,%d>%n", &ct, &os, &l);
sos_Object result;
if (l = s1.length())
result = make_sos_Id_object
(sos_Id::make (sos_Container::make (ct), sos_Offset (os)));
else
result = NO_OBJECT;
return result;
}
// ==========================================================================
// generic conversion operations for scalar types
// ==========================================================================
// *************************************************************************
void sos_extern_from_object (void *addr,
sos_Object o,
void bcopy_to (void*,void*),
sos_Id tp)
// *************************************************************************
{ T_PROC ("sos_extern_from_object");
TT (knl_M, T_ENTER);
if (o.typed_id().get_tp() != tp)
err_raise (err_SYS, err_SOS_TYPE_ERROR, "sos_extern_from_object", FALSE);
sos_Id id = o.typed_id().get_id();
bcopy_to (addr, &id);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
sos_Scalar_object sos_object_from_extern (void *addr,
void bcopy_from (void*,void*),
sos_Id tp)
// *************************************************************************
{ T_PROC ("sos_object_from_extern");
TT (knl_M, T_ENTER);
sos_Id id = NOID;
// assures that the mapping scalar value - id is a bijection;
// -> preserves equality and ordering.
bcopy_from (addr, &id);
sos_Scalar_object obj = sos_Scalar_object::make (sos_Typed_id::make (id, tp));
TT (knl_M, T_LEAVE);
return obj;
}
// *************************************************************************
sos_Int sos_Int_from_enum (sos_Object o, sos_Type et)
// *************************************************************************
{ T_PROC ("sos_Int_from_enum");
TT (knl_M, T_ENTER);
#ifdef BOOT
err_assert (FALSE, "sos_Int_from_enum:BOOT");
#endif
if (NOT o.has_type (et))
err_raise (err_SYS, err_SOS_TYPE_ERROR, "sos_Int_from_enum", FALSE);
sos_Int size = et.get_object_size();
sos_Id id = o.typed_id ().get_id();
sos_Int result;
if (size == 1)
result = *(sos_Char*)&id;
else
{ err_assert (size == 2, "sos_Int_from_enum:invalid size");
result = *(sos_Short*)&id;
}
TT (knl_M, T_LEAVE);
return result;
}
// *************************************************************************
sos_Scalar_object sos_enum_from_sos_Int (sos_Int i, sos_Type et)
// *************************************************************************
{
T_PROC ("sos_enum_from_sos_Int");
TT (knl_M, T_ENTER);
#ifdef BOOT
err_assert (FALSE, "sos_enum_from_sos_Int:BOOT");
#endif
sos_Int size = et.get_object_size();
sos_Id id;
if (size == 1)
*(sos_Char*)&id = i;
else
{ err_assert (size == 2, "sos_enum_from_sos_Int:invalid size");
*(sos_Short*)&id = i;
}
sos_Scalar_object result =
sos_Scalar_object::make (sos_Typed_id::make (id, et.typed_id().get_id()));
TT (knl_M, T_LEAVE);
return result;
}
// ==========================================================================
// handle container local references
// ==========================================================================
// *************************************************************************
sos_Typed_id sos_make_local_typed_id (sos_Offset os, sos_Container ct)
// *************************************************************************
{ if (os == 0) return NOTPID;
else
{ sos_Id id = sos_Id::make (ct, os);
return sos_Typed_id::make (id, id.get_type_id());
}
};
// *************************************************************************
sos_Offset sos_local_offset (sos_Object o, sos_Container ct)
// *************************************************************************
{ sos_Offset os = o.typed_id().offset();
if (os != 0 AND o.container() != ct)
err_raise (err_SYS, err_SOS_INVALID_ASSIGNMENT_TO_LOCAL,
"assignment to a component that is declared to be local", FALSE);
return os;
};
// ==========================================================================
// C++ class / external type sos_Id
// ==========================================================================
// *************************************************************************
void sos_Id::set_type_id (sos_Id tp)
// *************************************************************************
{ union { sos_Id dummy;
char c[SOS_ID_SIZE]; } u;
bcopy_from_sos_Id (&tp, &u);
container().write (offset(), SOS_ID_SIZE, &u);
}
// *************************************************************************
sos_Id sos_Id::get_type_id ()
// *************************************************************************
{ sos_Id tp;
union { sos_Id dummy;
char c[SOS_ID_SIZE]; } u;
container().read (offset(), SOS_ID_SIZE, &u);
bcopy_to_sos_Id (&tp, &u);
return tp;
}
// ==========================================================================
// C++ class / external type sos_Typed_id
// ==========================================================================
// *************************************************************************
sos_Typed_id sos_Typed_id::make (sos_Id id)
// *************************************************************************
{ return sos_Typed_id::make (id, id.get_type_id());
};
// *************************************************************************
sos_Typed_id sos_Typed_id::allocate (sos_Type tp, sos_Container ct)
// *************************************************************************
{ T_PROC ("sos_Typed_id::allocate");
TT (knl_M, T_ENTER; TI ((sos_Int) ct));
#if BOOT
err_assert (FALSE, "sos_Typed_id::allocate");
#endif
sos_Typed_id tpid = allocate (tp, ct, tp.get_object_size());
TT (knl_M, T_LEAVE);
return tpid;
}
// *************************************************************************
sos_Typed_id sos_Typed_id::allocate (sos_Type tp,
sos_Container ct,
sos_Int object_size)
// *************************************************************************
{
T_PROC ("sos_Typed_id::allocate");
TT (knl_M, T_ENTER; TI (tp.container()); TI (tp.offset());
TI ((sos_Int) ct); TI (object_size));
sos_Offset os = ct.allocate (object_size);
sos_Id id = sos_Id::make (ct, os);
sos_Id tp_id = tp.typed_id().get_id();
id.set_type_id (tp_id);
sos_Typed_id tpid = sos_Typed_id::make (id, tp_id);
TT (knl_M, T_LEAVE; TI (os));
return tpid;
}
// ==========================================================================
// class sos_Object
// ==========================================================================
// *************************************************************************
sos_Type sos_Object::type ()
// *************************************************************************
{
T_PROC ("sos_Object::type");
TT (knl_H, T_ENTER);
sos_Id id = self.typed_id().get_tp ();
#if BOOT
sos_Typed_id tpid = sos_Typed_id::make (id, _sos_Type_type);
#else
sos_Typed_id tpid = sos_Typed_id::make (id);
#endif
sos_Type t = sos_Type::make (tpid);
TT (knl_H, T_LEAVE);
return t;
} // ** type **
// *************************************************************************
sos_Bool sos_Object::has_type (sos_Type tp)
// *************************************************************************
{
T_PROC ("sos_Object::has_type");
TT (knl_H, T_ENTER);
sos_Bool b = (self.typed_id().get_tp() == tp.typed_id().get_id());
TT (knl_H, T_LEAVE; TB(b));
return b;
} // ** has_type **
// *************************************************************************
sos_Bool sos_Object::isa (sos_Type tp)
// *************************************************************************
{
T_PROC ("sos_Object::isa");
TT (knl_H, T_ENTER);
sos_Bool b;
if (self.has_type (tp))
b = TRUE;
else
{
#if BOOT
err_assert (FALSE, "isa");
#endif
b = self.type().is_derived_from (tp);
}
TT (knl_H, T_LEAVE; TB(b));
return b;
} // ** isa **
// *************************************************************************
sos_Bool sos_Object::is_some (sos_Type tp)
// *************************************************************************
{
T_PROC ("sos_Object::is_some");
TT (knl_H, T_ENTER);
#if BOOT
err_assert (FALSE, "is_some");
#endif
sos_Bool b = self.type().is_derived_from_some (tp);
TT (knl_H, T_LEAVE; TB(b));
return b;
} // ** is_some **
// *************************************************************************
sos_Int sos_Object::size ()
// *************************************************************************
{
T_PROC ("sos_Object::size");
TT (knl_H, T_ENTER);
sos_Int i = self.container().rounded (self._size());
TT (knl_H, T_LEAVE; TI (i));
return i;
} // ** size **
// **************************************************************************
sos_Bool sos_Object::is_value ()
// **************************************************************************
{
// value components are not supported in this version!
T_PROC ("sos_Object::is_value");
TT (knl_H, T_ENTER);
err_raise_not_implemented ("sos_Object::is_value");
sos_Offset o = self.offset(); // suppress compiler warnings
TT (knl_H, T_LEAVE);
return FALSE;
} // ** is_value **
// *************************************************************************
sos_Bool sos_Object::identical (sos_Object anobject)
// *************************************************************************
{ return self.typed_id() == anobject.typed_id();
} // ** identical **
// *************************************************************************
sos_Bool sos_Object::operator== (sos_Object anobject)
// *************************************************************************
{ return self.typed_id() == anobject.typed_id();
} // ** operator== **
// *************************************************************************
sos_Bool sos_Object::operator!= (sos_Object anobject)
// *************************************************************************
{ return self.typed_id() != anobject.typed_id();
} // ** operator!= **
// *************************************************************************
sos_Bool sos_Object::like (sos_Object anobject)
// *************************************************************************
{ return anobject.equal (self, /*eq_kind*/ EQ_WEAK);
} // ** like **
// **************************************************************************
sos_Comp_result sos_Object::compare_ids (sos_Object o)
// **************************************************************************
{ T_PROC ("sos_Object::compare_ids");
TT (knl_H, T_ENTER);
sos_Typed_id tpid1 = self.typed_id();
sos_Typed_id tpid2 = o.typed_id();
int cmp_val = tpid1.get_id().offset() - tpid2.get_id().offset();
if (cmp_val EQ 0)
{ cmp_val = tpid1.get_id().container() - tpid2.get_id().container();
if (cmp_val EQ 0)
{ cmp_val = tpid1.get_tp().offset() - tpid2.get_tp().offset();
if (cmp_val EQ 0)
cmp_val = tpid1.get_tp().container() - tpid2.get_tp().container();
}
}
sos_Comp_result result = make_comp_result (cmp_val);
TT (knl_H, T_LEAVE);
return result;
}
// *************************************************************************
void sos_Object::local_assign (sos_Object, sos_Object)
// *************************************************************************
{
T_PROC ("sos_Object::local_assign");
TT (knl_M, T_ENTER);
// do nothing.
// note that the generated local_assign would copy
// the component 'type_id'
TT (knl_M, T_LEAVE);
} // ** local_assign **
// *************************************************************************
sos_Bool sos_Object::local_equal (sos_Object,sos_Object,sos_Eq_kind)
// *************************************************************************
{
T_PROC ("sos_Object::local_equal");
TT (knl_M, T_ENTER);
sos_Bool result = TRUE;
// note that the generated local_equal would compare
// the component 'type_id'
TT (knl_M, T_LEAVE; TB(result));
return result;
} // ** local_equal **
// *************************************************************************
sos_Int sos_Object::local_hash_value (sos_Object)
// *************************************************************************
{
T_PROC ("sos_Object::local_hash_value");
TT (knl_M, T_ENTER);
sos_Int result = 0;
TT (knl_M, T_LEAVE; TI (result));
return result;
} // ** hash_value **
// ==========================================================================
// class sos_Ordered_object
// ==========================================================================
// *************************************************************************
sos_Bool sos_Ordered_object::operator< (sos_Ordered_object o)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::operator<");
TT (knl_H, T_ENTER);
sos_Bool result = (sos_Bool)(self.compare (o) == CMP_LESS);
TT (knl_H, T_LEAVE);
return result;
}
// *************************************************************************
sos_Bool sos_Ordered_object::operator<= (sos_Ordered_object o)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::operator<=");
TT (knl_H, T_ENTER);
sos_Bool result = (sos_Bool)(self.compare (o) != CMP_GREATER);
TT (knl_H, T_LEAVE);
return result;
}
// *************************************************************************
sos_Bool sos_Ordered_object::operator> (sos_Ordered_object o)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::operator>");
TT (knl_H, T_ENTER);
sos_Bool result = (sos_Bool)(self.compare (o) == CMP_GREATER);
TT (knl_H, T_LEAVE);
return result;
}
// *************************************************************************
sos_Bool sos_Ordered_object::operator>= (sos_Ordered_object o)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::operator>");
TT (knl_H, T_ENTER);
sos_Bool result = (sos_Bool)(self.compare (o) != CMP_GREATER);
TT (knl_H, T_LEAVE);
return result;
}
// ==========================================================================
// class sos_Scalar_object
// ==========================================================================
// *************************************************************************
void sos_Scalar_object::local_initialize (sos_Scalar_object)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::local_initialize");
TT (knl_M, T_ENTER);
err_raise (err_USE, err_SOS_ILLEGAL_EXT_OP,
"sos_Scalar_object::local_initialize", FALSE);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
void sos_Scalar_object::local_finalize (sos_Scalar_object)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::local_finalize");
TT (knl_M, T_ENTER);
err_raise (err_USE, err_SOS_ILLEGAL_EXT_OP,
"sos_Scalar_object::local_finalize", FALSE);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
void sos_Scalar_object::local_assign (sos_Scalar_object, sos_Object)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::local_assign");
TT (knl_M, T_ENTER);
err_raise (err_USE, err_SOS_ILLEGAL_EXT_OP,
"sos_Scalar_object::local_assign", FALSE);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
sos_Bool sos_Scalar_object::local_equal (sos_Scalar_object x,
sos_Object o,
sos_Eq_kind )
// *************************************************************************
{ T_PROC ("sos_Scalar_object::local_equal");
TT (knl_M, T_ENTER);
sos_Bool result = x.identical (o);
TT (knl_M, T_LEAVE);
return result;
}
// *************************************************************************
sos_Int sos_Scalar_object::local_hash_value (sos_Scalar_object scalo)
// *************************************************************************
{ T_PROC ("sos_Scalar_object::local_hash_value");
TT (knl_M, T_ENTER);
sos_Int result = scalo.offset();
TT (knl_M, T_LEAVE);
return result;
}
// ==========================================================================
// class sos_String
// ==========================================================================
// *************************************************************************
void sos_String::operator+= (sos_String s)
// *************************************************************************
{ T_PROC ("sos_String::operator+=");
TT (knl_H, T_ENTER);
smg_String cat = smg_String (self) + s;
self.assign_Cstring (cat.make_Cstring (SMG_BORROW));
TT (knl_H, T_LEAVE);
}
// *************************************************************************
void sos_String::assign_Cstring (sos_Cstring s)
// *************************************************************************
{ T_PROC ("sos_String::assign_Cstring");
TT (knl_H, T_ENTER);
sos_Int size = strlen (s),
old_size = self.get_length();
sos_Container ct = self.container();
if (old_size != size)
{ self.set_length (size);
if (old_size > 0) // remove the old contents
ct.deallocate (self.get_address(), old_size);
}
if (size > 0)
{ sos_Offset new_addr;
if (old_size == size) // it's not necessary to allocate new space
new_addr = self.get_address();
else
{ new_addr = ct.allocate (size);
self.set_address (new_addr);
}
ct.write (new_addr, size, s);
}
TT (knl_H, T_LEAVE; TI (old_size); TI (size));
}
// *************************************************************************
sos_Cstring sos_String::make_Cstring ()
// *************************************************************************
{ T_PROC ("sos_String::make_Cstring");
TT (knl_H, T_ENTER);
sos_Int size = self.get_length();
sos_Cstring s = new char[size+1];
self.container().read (self.get_address(), size, s);
s[size] = '\0';
TT (knl_H, T_LEAVE; TI (size));
return s;
}
// **************************************************************************
sos_Int sos_String::size()
// **************************************************************************
{ T_PROC ("sos_String::size");
TT (knl_H, T_ENTER);
sos_Int sz = self.container().rounded (self.get_length()) +
sos_Object::size();
TT (knl_H, T_LEAVE);
return sz;
}
// **************************************************************************
sos_Comp_result sos_String::compare (sos_Ordered_object o)
// **************************************************************************
{ T_PROC ("sos_String::compare");
TT (knl_H, T_ENTER);
if (NOT o.isa (sos_String_type))
err_raise (err_SYS, err_SOS_TYPE_ERROR, "sos_String::compare", FALSE);
smg_String s1 = self;
smg_String s2 = sos_String::make (o);
sos_Comp_result result = make_comp_result (s1.compare (s2));
TT (knl_H, T_LEAVE);
return result;
}
// *************************************************************************
void sos_String::local_initialize (sos_String str)
// *************************************************************************
{ T_PROC ("sos_String::local_initialize");
TT (knl_M, T_ENTER);
str.set_length (0);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
void sos_String::local_finalize (sos_String str)
// *************************************************************************
{ T_PROC ("sos_String::local_finalize");
TT (knl_M, T_ENTER);
sos_Int size = str.get_length();
if (size > 0)
str.container().deallocate (str.get_address(), size);
TT (knl_M, T_LEAVE);
}
// *************************************************************************
void sos_String::local_assign (sos_String x, sos_Object o)
// *************************************************************************
{ T_PROC ("sos_String::local_assign");
TT (knl_M, T_ENTER);
smg_String ostring = sos_String::make (o);
x.assign_Cstring (ostring.make_Cstring (SMG_BORROW));
TT (knl_M, T_LEAVE);
}
// *************************************************************************
sos_Bool sos_String::local_equal (sos_String x,
sos_Object o,
sos_Eq_kind eq_kind)
// *************************************************************************
{ T_PROC ("sos_String::local_equal");
TT (knl_M, T_ENTER);
sos_Bool result;
if ((eq_kind EQ EQ_STRONG AND NOT o.has_type (sos_String_type)) OR
(eq_kind EQ EQ_WEAK AND NOT o.isa (sos_String_type)))
result = FALSE;
else
{ sos_String y = sos_String::make (o);
sos_Int l_y = y.get_length();
result = (sos_Bool)(x.get_length() == l_y AND
x.container().equal(x.get_address(), l_y,
y.container(), y.get_address()));
}
TT (knl_M, T_LEAVE; TB(result));
return result;
}
// *************************************************************************
sos_Int sos_String::local_hash_value (sos_String x)
// *************************************************************************
{ T_PROC ("sos_String::local_hash_value");
TT (knl_M, T_ENTER);
sos_Int result = x.container().hash_value (x.get_address(), x.get_length());
TT (knl_M, T_LEAVE; TI (result));
return result;
}
// ==========================================================================
// class sos_Type
// ==========================================================================
// *************************************************************************
sos_Type sos_type_object (sos_Id id, sos_Id tp)
// *************************************************************************
{
#if BOOT
sos_Typed_id tpid = sos_Typed_id::make (id, _sos_Type_type);
#else
sos_Typed_id tpid = sos_Typed_id::make (id, tp);
#endif
return sos_Type::make (tpid);
} // ** sos_type_object **
// *************************************************************************
sos_Bool sos_Type::is_derived_from (sos_Type tp)
// *************************************************************************
{
T_PROC ("sos_Type::is_derived_from");
TT (knl_H, T_ENTER);
sos_Bool result = self.equal (tp);
TT (knl_H, T_LEAVE; TB (result));
return result;
}
// *************************************************************************
sos_Bool sos_Type::is_derived_from_some (sos_Type tp)
// *************************************************************************
{
T_PROC ("sos_Type::is_derived_from_some");
TT (knl_H, T_ENTER);
sos_Bool result = self.equal (tp);
TT (knl_H, T_LEAVE; TB (result));
return result;
}
// *************************************************************************
sos_Bool sos_Type::is_scalar ()
// *************************************************************************
{
T_PROC ("sos_Type::is_scalar");
TT (knl_H, T_ENTER);
sos_Bool result = FALSE; // Default-Implementation.
// This method is redefined in
// class sos_Scalar_type!
TT (knl_H, T_LEAVE; TB (result));
return result;
}
// *************************************************************************
sos_Type sos_Type::base ()
// *************************************************************************
{
T_PROC ("sos_Type::base");
TT (knl_H, T_ENTER);
sos_Type t = self;
TT (knl_H, T_LEAVE);
return t;
}
// *************************************************************************
sos_Type sos_Type::root ()
// *************************************************************************
{
T_PROC ("sos_Type::root");
TT (knl_H, T_ENTER);
sos_Type t = self.base();
TT (knl_H, T_LEAVE);
return t;
}